home *** CD-ROM | disk | FTP | other *** search
-
-
-
- FTW(3) MINTLIB LIBRARY FUNCTIONS FTW(3)
-
-
- N✓NA✓AM✓ME✓E
- ftw - walk a file tree
-
- S✓SY✓YN✓NO✓OP✓PS✓SI✓IS✓S
- #include <ftw.h>
-
- int ftw(char *path, int (*fn)(char *, struct stat *, int), int depth);
-
- D✓DE✓ES✓SC✓CR✓RI✓IP✓PT✓TI✓IO✓ON✓N
- ftw recursively descends the directory hierarchy rooted in
- path. For each object in the hierarchy, ftw calls the
- user-supplied function fn, passing it a pointer to a null-
- terminated character string containing the name of the
- object, a pointer to a stat structure containing informa-
- tion about the object, and an integer. Possible values of
- the integer, defined in the <ftw.h> header file, are FTW_F
- for a file, FTW_D for a directory, FTW_DNR for a directory
- that cannot be read, and FTW_NS for an object for which
- stat could not successfully be executed. If the integer is
- FTW_DNR, descendants of that directory will not be pro-
- cessed. An example of an object that would cause FTW_NS to
- be passed to fn would be a file in a directory with read
- but without execute (search) permission.
-
- ftw visits a directory before visiting any of its descen-
- dants.
-
- The tree traversal continues until the tree is exhausted,
- an invocation of fn returns a nonzero value, or some error
- is detected within ftw (such as an I/O error). If the tree
- is exhausted, ftw returns zero. If fn returns a nonzero
- value, ftw stops its tree traversal and returns whatever
- value was returned by fn. If ftw detects an error, it
- returns -1, and sets the error type in errno.
-
- ftw uses one file descriptor for each level in the tree.
- The depth argument limits the number of file descriptors
- so used. If depth is zero or negative, the effect is the
- same as if it were 1. Depth must not be greater than the
- number of file descriptors currently available for use.
- ftw will run more quickly if depth is at least as large as
- the number of levels in the tree.
-
- S✓SE✓EE✓E A✓AL✓LS✓SO✓O
- s✓st✓ta✓at✓t(✓(3✓3)✓)
-
- N✓NO✓OT✓TE✓ES✓S
- Note that MiNT limits each process to 32 file descriptors.
- Since three are normally used for standard input, output
- and error output, only few remain.
-
- C library functions like this are usually only found after
- a similar version has already been written by the program-
- mer.
-
-
-
- MiNT docs 0.1 3 March 1993 1
-
-
-
-
-
- FTW(3) MINTLIB LIBRARY FUNCTIONS FTW(3)
-
-
- B✓BU✓UG✓GS✓S
- Because ftw is recursive, it is possible for it to termi-
- nate with a memory fault when applied to very deep file
- structures.
-
- Symbolic links are reported to the user-supplied function
- as FTW_F.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- MiNT docs 0.1 3 March 1993 2
-
-
-